<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>模块模式</title>
</head>
<body>

</body>
</html>

<script>
  /*
  * 单例模式添加私有属性和私有方法
  * */
  const module =  function (name) {
    this.name = 'GaoSir'
  }

  module.prototype.getName = function () {
    return this.name
  }

  const application = (function () {
    const private1 = 'private1'
    const private2 = function () {
      return 'private2'
    }
    let obj = new module()
    obj.public1 = 'public1'
    obj.public2 = function () {
      return private1
    }

    return obj
  })()

  console.log(application.public1)

  console.log(application.public2())

  console.log(application.name)

  console.log(application.getName())
</script>